<template>
  <div>
    <a-menu
      theme="dark"
      mode="inline"
      :open-keys="openKeys"
      style="width: 256px"
      @openChange="onOpenChange"
    >
      <a-sub-menu key="sub2">
        <span slot="title"><a-icon type="check" /><span>用户管理</span></span>
        <a-menu-item key="4" @click="guanliyuan">
          管理员管理
        </a-menu-item>
        <a-menu-item key="5" @click="xuesheng">
          学生管理
        </a-menu-item>
      </a-sub-menu>
      <a-sub-menu key="sub3">
        <span slot="title"
          ><a-icon type="check" /><span>课堂内容管理</span></span
        >
        <a-menu-item key="9" @click="ketangneirong">
          课堂内容管理
        </a-menu-item>
      </a-sub-menu>
      <a-sub-menu key="sub5">
        <span slot="title"
          ><a-icon type="check" /><span>作业管理及考评</span></span
        >
        <a-menu-item key="13" @click="routerJump(0)">
          发布作业
        </a-menu-item>
        <a-menu-item key="14" @click="routerJump(1)">
          评判作业
        </a-menu-item>
        <a-menu-item key="15" @click="routerJump(2)">
          成绩管理
        </a-menu-item>
      </a-sub-menu>
    </a-menu>
  </div>
</template>
<script>
export default {
  data() {
    return {
      rootSubmenuKeys: ['sub1', 'sub2', 'sub4'],
      openKeys: ['sub2'],
    }
  },
  methods: {
    onOpenChange(openKeys) {
      const latestOpenKey = openKeys.find(
        key => this.openKeys.indexOf(key) === -1
      )
      if (this.rootSubmenuKeys.indexOf(latestOpenKey) === -1) {
        this.openKeys = openKeys
      } else {
        this.openKeys = latestOpenKey ? [latestOpenKey] : []
      }
    },
    guanliyuan() {
      this.$router.push('/manage/guanliyuanguanli')
    },
    xuesheng() {
      this.$router.push('/manage/xueshengguanli')
    },
    ketangneirong() {
      this.$router.push('/manage/ketangneirongguanli')
    },
    routerJump(val) {
      if (val === 0) this.$router.push('/manage/publishHomework')
      if (val === 1) this.$router.push('/manage/judgeHomework')
      if (val === 2) this.$router.push('/manage/gradeManage')
    },
  },
}
</script>
